<?php
mysql_select_db($database_konek, $konek);
$query_past = "SELECT * FROM template WHERE id = $pilih_sett";
$past = mysql_query($query_past, $konek) or die(mysql_error());
$row_past = mysql_fetch_assoc($past);
$totalRows_past = mysql_num_rows($past);
?>
<?php
mysql_select_db($database_konek, $konek);
$query_past2 = "SELECT * FROM template_data WHERE id_module = '$row_past[id]' LIMIT $row_past[perpage] ";
$past2 = mysql_query($query_past2, $konek) or die(mysql_error());
$row_past2 = mysql_fetch_assoc($past2);
$totalRows_past2 = mysql_num_rows($past2);
mysql_select_db($database_konek, $konek);
$query_sm = "SELECT * FROM template_data WHERE id_module = '$row_past[id]' ";
$sm = mysql_query($query_sm, $konek) or die(mysql_error());
$row_sm = mysql_fetch_assoc($sm);
$totalRows_sm = mysql_num_rows($sm);
if ($totalRows_past2>0){
?>
<div class="<?php echo $classjudul ?>">
<?php echo $row_past['judul']; ?>
</div>

<div class="<?php echo $classcontent; ?>">
<div class="row">
  <?php $num=0; do { ?>

  <div class="col-sm-6 col-md-3 col-lg-3">
    <div class="thumbnail">
      <img src="<?php echo $base_url ?>/g-konten/fm/template/<?php echo $row_past['id']; ?>/thumb/<?php echo $row_past2['image']; ?>" alt="<?php echo $num++ ?>" alt="<?php echo $row_past2['nama']; ?>">
      <div class="caption">
        <h3><?php echo $row_past2['nama']; ?></h3>
        <p><a href="#" class="btn btn-primary" role="button"> <i class="fa fa-external-link"></i> Live Demo</a> <a href="#" class="btn btn-default" role="button"><i class="fa fa-download"></i> Buy Now</a></p>
      </div>
    </div>
  </div>
    <?php } while ($row_past2 = mysql_fetch_assoc($past2)); ?>
</div>
<?php if ($totalRows_sm>$row_past['perpage']) { ?>
<div style="width:100%; margin-top:20px">
<div class="btn-group">
  <a href="<?php echo $base_url ?>/p/template/detail/<?php echo $row_past['id'] ?>/page/1">
  <button type="button" class="btn btn-default">Next</button>
  </a></div>
</div>
<?php } ?>
</div>
<?php
}
mysql_free_result($past2);
?>

<?php
mysql_free_result($past);
?>